package com.decapre.zufangwang.controller;

import com.decapre.zufangwang.entity.House;
import com.decapre.zufangwang.entity.dto.SearchParamDto;
import com.decapre.zufangwang.service.HouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/houses")
@Api(tags = "Houses")
public class HouseHandler {
    private HouseService houseService;

    @Autowired
    public  HouseHandler(HouseService houseService){
        this.houseService = houseService;
    }

    @GetMapping("")
    @ApiOperation("gethouses")
    public Map<String,Object> index(){
        return houseService.getAllHouses();
    }

    @PostMapping("")
    @ApiOperation("getHousesByForm")
    public Map<String, Object> getHousesByForm(
            @RequestBody SearchParamDto formData){
        return houseService.getHousesByForm(formData);
    }

}
